//加载所有游戏(value是游戏id+游戏名)
function loadGames(){
	$.ajax({
		type: "post",
		url: "/common/tool/loadGames",
		success: function(msg){
			var datas = msg.records;
			
			var html = "<option value=''>&nbsp;&nbsp;全部</option>";
			if(datas.length!=0){
				for(var i = 0; i < datas.length; i++){
					html += "<option value='"+datas[i].kindId+"/"+datas[i].kindName+"'>&nbsp;&nbsp;"+datas[i].kindName+"</option>";
				}
			}
			$("#game").html(html);
		}
	});
}
//加载所有游戏(value是kindId)
function loadGamesKindId(){
	$.ajax({
		type: "post",
		url: "/common/tool/loadGames",
		success: function(msg){
			var datas = msg.records;
			
			var html = "<option value=''>&nbsp;&nbsp;全部</option>";
			if(datas.length!=0){
				for(var i = 0; i < datas.length; i++){
					html += "<option value='"+datas[i].kindId+"'>&nbsp;&nbsp;"+datas[i].kindName+"</option>";
				}
			}
			$("#game").html(html);
		}
	});
}

//加载所有房间(value是房间名)
function loadRooms(obj){
	var game = $(obj).val();
	
	game = game.substring(game.indexOf("/")+1);
	
	$.ajax({
		type: "post",
		data: {"game":game},
		url: "/common/tool/loadRooms",
		success: function(msg){
			var datas = msg.records;
			var html = "<option value=''>&nbsp;&nbsp;全部</option>";
			if(datas.length!=0){
				for(var i = 0; i < datas.length; i++){
					html += "<option value='"+datas[i].roomName+"'>&nbsp;&nbsp;"+datas[i].roomName+"</option>";
				}
			}
			$("#room").html(html);
		}
	});
}

//加载所有房间(value是serverid)
function loadRoomServerId(obj){
	var game = $(obj).val();
	
	game = game.substring(game.indexOf("/")+1);
//	alert("game: "+game);
	$.ajax({
		type: "post",
		data: {"game":game},
		url: "/common/tool/loadRooms",
		success: function(msg){
			var datas = msg.records;
			var html = "<option value=''>&nbsp;&nbsp;全部</option>";
			if(datas.length!=0){
				for(var i = 0; i < datas.length; i++){
					html += "<option value='"+datas[i].serverId+"'>&nbsp;&nbsp;"+datas[i].roomName+"</option>";
				}
			}
			$("#room").html(html);
		}
	});
}